﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NDBGen.Tests
{
    [TestClass]
    public class IndentedTextWriterTests
    {
        [TestMethod]
        public void WritesIndented()
        {
            var b = new StringBuilderStream();

            var expected =
@"No indent
    Indentation Level 1
        Indentation Level 2
    Indentation Level 1
No indent
";
            String actual;

            using (var writer = new IndentedTextWriter(b))
            {
                writer.WriteLine("No indent");

                using (writer.Indent())
                {
                    writer.WriteLine("Indentation Level 1");

                    using(writer.Indent())
                    {
                        writer.WriteLine("Indentation Level 2");
                    }

                    writer.WriteLine("Indentation Level 1");
                }

                writer.WriteLine("No indent");
            }

            actual = b.ToString();
            Assert.AreEqual(expected, actual);
        }
    }
}